import 'package:flutter/material.dart';
import 'package:macnov/models/transaction.dart';

class TxnAvatar extends StatelessWidget {
  final TransactionModel txn;
  const TxnAvatar({Key key, @required this.txn}) : super(key: key);

  String _firstLatter() {
    if (txn.merchant.isNotEmpty) {
      return txn.merchant.substring(0, 1).toUpperCase();
    }
    return '';
  }

  @override
  Widget build(BuildContext context) {
    return new Container(
      width: 32.0,
      height: 32.0,
      decoration: BoxDecoration(
        shape: BoxShape.circle,
        color: Colors.black,
      ),
      child: Center(
        child: Text(
          _firstLatter(),
          style: TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}
